package com.itheima.controller;

import com.itheima.domain.HomeBrand;
import com.itheima.manager.SmsHomeBrandManager;
import com.itheima.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/home/brand")
public class SmsHomeBrandController {
    @Autowired
    SmsHomeBrandManager smsHomeBrandManager;

    //分页查询推荐品牌
    @GetMapping("/list")
    public Result list(Integer pageNum, Integer pageSize, String brandName,Integer recommendStatus){
        return smsHomeBrandManager.list(pageNum,pageSize,brandName,recommendStatus);
    }

    //添加首页推荐品牌
    @PostMapping("/create")
    public Result create(@RequestBody List<HomeBrand> homeBrandList){
        return smsHomeBrandManager.create(homeBrandList);
    }
    //批量删除推荐品牌
    @PostMapping("/delete")
    public Result delete(@RequestParam("ids") List<Long> ids){
        return smsHomeBrandManager.delete(ids);
    }

    //修改推荐品牌排序
    @PostMapping("/update/sort/{id}")
    public Result updateSort(@PathVariable Long id,Integer sort){
        return smsHomeBrandManager.updateSort(id,sort);
    }
    //批量修改推荐品牌状态
    @PostMapping("/update/recommendStatus")
    public Result updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam("recommendStatus")Integer recommendStatus){
        return smsHomeBrandManager.updateRecommendStatus(ids,recommendStatus);
    }

}
